#!/usr/bin/python
# -*- coding: UTF-8 -*-

################################################################################
#
# Copyright (c) 2020 openEuler.org, Inc. All Rights Reserved
#
################################################################################
"""
Email notification of incorrect data

Authors: xiaojianghui
Date:    10/22/2020 11:01 AM
"""

import os
from dbConnecttion import MysqlConn
from emailtask import sendemail


def sending():
    """
        Query all recipients
    """
    mysql = MysqlConn.Mysql()
    sql = "select email_name from cve_email_list where email_type=1"
    result = mysql.getMany(sql)
    mysql.close()
    print(result)
    for i in result:
        subject = "Form error data feedback(人工CVE漏洞数据错误反馈)"
        content = "The submitted CVE data is wrong, please check the format and content, please refer to the attachment"
        sendemail.send_email('mailman-exim4-service.mail.svc.cluster.local', 25,
                             os.getenv("CVE_EMAIL_SENDADDR"),
                             os.getenv("CVE_EMAIL_PASSWORD"),
                             str(i['email_name']), './problemexcels', subject, content)
